package com.wmlive.hhvideo.heihei.mainhome.widget;

import android.animation.TypeEvaluator;
import android.graphics.PointF;

/**
 * Created by vhawk on 2017/5/17.
 */

class BezierEvaluator implements TypeEvaluator<PointF> {


    private PointF controlPoint;


    public BezierEvaluator(PointF controlPoint) {
        this.controlPoint = controlPoint;
    }

    @Override
    public PointF evaluate(float fraction, PointF startValue, PointF endValue) {
        float oneMinusT = 1.0f - fraction;

        //startValue;    //开始出现的点
        //endValue;      //结束终点

        //贝塞尔曲线控制点
//        controlPoint = new PointF();
//        controlPoint.set(600, 200 / 2 - 300);

        PointF point = new PointF();    //返回计算好的点
        point.x = oneMinusT * oneMinusT * (startValue.x) + 2 * oneMinusT * fraction * (controlPoint.x) + fraction * fraction * (endValue.x);
        point.y = oneMinusT * oneMinusT * (startValue.y) + 2 * oneMinusT * fraction * (controlPoint.y) + fraction * fraction * (endValue.y);
        return point;
    }

}
